<%@page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!-- public quote -->
<%@include file="/jsp/comm_css_include.jsp"%>
<!doctype html>
<html>
<head>
<style type="text/css">
* {
	margin: 0px;
	padding: 0px;
	font-size: 12px;
}
</style>
</head>
<body class="gray-bg">

	<!-- 隐藏域 -->
	<input type="hidden" id="busiId" name="busiId" value="${busiId}" />
	<!-- 隐藏域 -->

	<div class="wrapper wrapper-content animated fadeInRight">
		<div class="iboxtitle">
			<span><i class="glyphicon glyphicon-map-marker"></i>&nbsp;财务相关>登记业务提成</span>
		</div>
		<div class="buttonfixed">
			<button type="button" class="btn dpbtn_blue" onclick="save();">发起申请</button>
		</div>
		<%-- <div class="ibox-content ibox-con">
				<%@include file="/jsp/common_yw_include.jsp"%>
				<div class="business-manwife">业务进程</div>
				<div class="business-padding" id="">
					<table class="yw-course">
						  <thead>
						    <tr>
						        <th id="added_status1" equal="0"   class="splztab">按揭日报表</th>
						        <th id="cwRebate" equal="10"  class="splztab">业务返利</th>
						        <th id="dianzi" equal="30"  class="splztab">申请垫资</li>
			           			<!-- <th id="M_jhsc" equal="40"  class="splztab">稽核审查</th> -->
			           			<th id="M_cwshy" equal="50"  class="splztab">财务审核1</th>
			           			<!--<th id="M_cwshe" equal="200" class="splztab">财务审核2</th>-->
			           			<!--<th id="caiwu3" class="splztab">财务审核3</th>-->
			           			<th id="caiwudiankuan" class="splztab">财务垫款</th>
						    </tr>
						  </thead>
						  <thead>
						    <tr>
						        <th id="" class="splztab">数据调整</th>
			           			<th id="" class="splztab">返利调整</th>
			           			<th id="" equal="70" class="splztab">稽核审查2</th>
			           			<th id="" equal="80" class="splztab">财务调整</th>
						    </tr>
						  </thead>
						</table>
				</div> --%>
		<div class="business-manwife">车贷信息</div>
		<div class="business-padding">
			<table cellpadding="0" cellspacing="0" border="0"
				class="infor-table list-table-detail">
				<tr>
					<td align="right"><label class="control-label np">贷款银行：</label>
					</td>
					<td colspan="3">
						<div class="control-div np" id="loan_loanBank" name="loanBank">-</div>
					</td>
				</tr>
				<tr>
					<td align="right"><label class="control-label np">贷款模式：</label>
					</td>
					<td>
						<div class="control-div np" id="loan_loanType" name="loanType">-</div>
					</td>

					<td align="right"><label class="control-label np">购入价：</label>
					</td>
					<td>
						<div class="control-div np" id="loan_carPrice" name="carPrice">-</div>
					</td>
				</tr>
				<tr>
					<td align="right"><label class="control-label np">实际贷款额：</label>
					</td>
					<td>
						<div class="control-div np" id="loan_loanAmount" name="loanAmount">-</div>
					</td>
				</tr>
				<tr class="used-car">
					<td align="right"><label class="control-label np">二手车估价：</label>
					</td>
					<td>
						<div class="control-div np" id="loan_carEstimatePrice"
							name="carEstimatePrice">-</div>
					</td>

					<td align="right"><label class="control-label np">二手车车龄(月)：</label>
					</td>
					<td>
						<div class="control-div np" id="loan_carAge" name="carAge">-</div>
					</td>
				</tr>

				<tr>
					<td align="right"><label class="control-label np">银行基准利率：</label>
					</td>
					<td>
						<div class="control-div np" id="loan_bankRate" name="bankRate">-</div>
					</td>
					<td align="right"><label class="control-label np">贷款期限：</label>
					</td>
					<td>
						<div class="control-div np" id="loan_loanMonth" name="loanMonth">-</div>
					</td>
					<td colspan="2" class="used-car"><label
						class="control-label np color-red">注：该二手车贷款期限受限</label></td>
				</tr>

				<tr>
					<td align="right" class="d1 d2"><label
						class="control-label np" class="d1 d2">按揭服务费：</label></td>
					<td class="d1 d2">
						<div class="control-div np" id="loan_servicePrice"
							name="servicePrice">-</div>
					</td>
					<td align="right" class="d2"><label class="control-label np">签约公司利率：</label>
					</td>
					<td id="companyRateInput" class="d2">
						<div class="control-div np" id="loan_companyRate"
							name="companyRate">-</div>
					</td>
				</tr>

				<tr class="d1 d2 d3">
					<td align="right"><label class="control-label np">签约贷款额：</label>
					</td>
					<td>
						<div class="control-div np" id="loan_signLoanAmount"
							name="signLoanAmount">-</div>
					</td>

					<td align="right"><label class="control-label np">签约总还款额：</label>
					</td>
					<td>
						<div class="control-div np" id="loan_totalRepaymentAmount"
							name="totalRepaymentAmount">-</div>
					</td>
				</tr>
				<tr>
					<td align="right" class="d1 d2"><label
						class="control-label np">银行利息：</label></td>
					<td class="d1 d2">
						<div id="loan_bankRateAmount" name="bankRateAmount"
							class="control-div">-</div>
					</td>
					<td align="right"><label class="control-label np">签约月还款额：</label>
					</td>
					<td>
						<div class="control-div np amountMonthly" id="loan_amountMonthly"
							name="amountMonthly">-</div>
					</td>
					<td align="right" class="d3"><label class="control-label np">签约首月还款额：</label>
					</td>
					<td class="d3">
						<div id="loan_firstMonthTotalAmount" name="firstMonthTotalAmount"
							class="control-div">-</div>
					</td>
				</tr>

				<tr class="d3">
					<td align="right"><label class="control-label np">每月本金还款额：</label>
					</td>
					<td>
						<div class="control-div np" id="loan_monthlyPrincipalAmount"
							name="monthlyPrincipalAmount">-</div>
					</td>

					<td align="right"><label class="control-label np">每月手续费：</label>
					</td>
					<td>
						<div class="control-div np" id="loan_monthlyFee" name="monthlyFee">-</div>
					</td>
				</tr>

				<tr class="d3">
					<td align="right"><label class="control-label np">首月本金还款额：</label>
					</td>
					<td>
						<div class="control-div np" id="loan_firstMonthAmount"
							name="firstMonthAmount">-</div>
					</td>

					<td align="right"><label class="control-label np">首月手续费：</label>
					</td>
					<td>
						<div class="control-div np" id="loan_firstMonthFee"
							name="firstMonthFee">-</div>
					</td>
				</tr>
			</table>
		</div>
		<div class="business-manwife">申请返利</div>
		<form class="form-horizontal m-t" id="commentForm">
			<div class="padding-nono">
				<table cellpadding="0" cellspacing="0" border="0"
					class="buyinfor-table">
					<tr>
						<td align="right"><label class="control-label np">申请返利金额：</label>
						</td>
						<td><input class="form-control" type="number"
							id="amount_rebate" name="amount_rebate" required="required"
							value="${cwRebate.amountRebate}" placeholder="申请返利金额(必填)" /></td>
					</tr>
				</table>
			</div>
		</form>
		<div class="business-manwife">经办信息</div>
		<div class="padding-nono">
			<table cellpadding="0" cellspacing="0" border="0"
				class="buyinfor-table">
				<tr>
					<td align="right"><label class="control-label np">经办人：</label>
					</td>
					<td><input class="form-control" type="text" id="uname"
						name="uname" readonly="readonly" value="${current_user_key.uname}" />
					</td>
					<td align="right"><label class="control-label np">经办时间：</label>
					</td>
					<td><input id="jb_time" name="jb_time" placeholder="经办时间"
						readonly="readonly" class="laydate-icon form-control" /></td>
				</tr>
			</table>
		</div>
	</div>
	</div>

	<!-- public quote -->
	<%@include file="/jsp/comm_js_include.jsp"%>

	<!-- layerDate plugin javascript -->
	<script type="text/javascript"
		src="${basePath}/js/plugins/layer/laydate/laydate.js"></script>

	<!-- custom js -->
	<%@include
		file="/js/common-dpqc/dpqc-validate/comm_validate_include.jsp"%>
	<script type="text/javascript"></script>

	<!--
    	作者：zhangpp
    	时间：2017-04-06
    	描述：js
    -->
	<script type="text/javascript">
    	$(function(){
    		$("#commentForm").validate({
    	        //重写showErrors
    	        showErrors: function (errorMap, errorList) {
    	            
    	            $.each(errorList, function (i, v) {
    	                layer.tips(v.message, v.element, { time: 1500 });
    	                return false;
    	            });  
    	        },
    	        /* 失去焦点时验证 */
    	        onfocusout: function(element) {$(element).valid(); },
    	        /*  键盘抬起不验证 */
    	        onkeyup:false,
    	    });
    		
    		var date = new Date();
	    	document.getElementById("jb_time").value = date.format("yyyy-MM-dd h:m:s");
	    	
	    	initData();
    	});
    	
    	//初始化查询
    	var initData = function()
    	{
    		var busiId = $('#busiId').val();
    		
    		$.dpAjax({
 				show:false,
	 			url:'${basePath}/CaiWuXiangGuanController/dakuanDetail',
	 			data:{
	 				"busiId":busiId
	 			},
	 			success: function(datas)
	 			{
	 				  if(datas.flag == "100100")
	 				  {		
	 					    //车贷信息
	 	     			    var ywBusinessLoan = datas.ywBusinessLoan;
	 					    if(ywBusinessLoan)
	 					    {
	 					    	$('#loan_loanBank').text(ywBusinessLoan.loanBankDisplay);
		 	     				$('#loan_loanType').text(ywBusinessLoan.loanTypeDisplay);
		 	     				$('#loan_carPrice').text(showBigNumber(ywBusinessLoan.carPrice));
		 	     				$('#loan_carEstimatePrice').text(showBigNumber(ywBusinessLoan.carEstimatePrice));
		 	     				$('#loan_carAge').text(ywBusinessLoan.carAge);
		 	     				$('#loan_loanMonth').text(ywBusinessLoan.loanMonthDisplay);
		 	     				$('#loan_bankRate').text(showNumber(ywBusinessLoan.bankRate));
		 	     				$('#loan_loanAmount').text(showBigNumber(ywBusinessLoan.loanAmount));
		 	     				$('#loan_companyRate').text(showNumber(ywBusinessLoan.companyRate));
		 	     				$('#loan_servicePrice').text(showNumber(ywBusinessLoan.servicePrice));
		 	     				
		 	     				//结果字段
		 	     				$('#loan_signLoanAmount').text(showNumber(ywBusinessLoan.signLoanAmount));
		 	     				$('#loan_totalRepaymentAmount').text(showNumber(ywBusinessLoan.totalRepaymentAmount));
		 	     				$('#loan_bankRateAmount').text(showNumber(ywBusinessLoan.bankRateAmount));
		 	     				$('#loan_amountMonthly').text(showNumber(ywBusinessLoan.amountMonthly));
		 	     			    $('#loan_zhkcj').text(showNumber(ywBusinessLoan.zhkcj * 100));
		 	     			    $('#loan_qyhkcj').text(showNumber(ywBusinessLoan.qyhkcj * 100));
		 	     			    $('#loan_firstMonthTotalAmount').text(showNumber(ywBusinessLoan.firstMonthTotalAmount));
		 	     			    $('#loan_monthlyPrincipalAmount').text(showNumber(ywBusinessLoan.monthlyPrincipalAmount));
		 	     			    $('#loan_firstMonthAmount').text(showNumber(ywBusinessLoan.firstMonthAmount));
		 	     				$('#loan_monthlyFee').text(showNumber(ywBusinessLoan.monthlyFee));
		 	     				$('#loan_firstMonthFee').text(showNumber(ywBusinessLoan.firstMonthFee));
	 					    }
	 					  return;
	 				  }
	 				  if(datas.flag == "100200")
	 				  {
	 					  alert(JSON.stringify(datas));
	 					  return;
	 				  }
	 				  layer.msg(datas.message, {icon: 5});
	 		     }
	 		});
    		
    		//业务进程
    		$.dpAjax({
 				show:false,
	 			url:'${basePath}/CaiWuXiangGuanController/getYwJinCheng',
	 			data:{
	 				"busiId":busiId
	 			},
	 			success: function(datas)
	 			{
	 				  if(datas.flag == "100100")
	 				  {		
	 					  //业务信息表
	 					  var ywBusiness = datas.ywBusiness;
	 					  if(ywBusiness)
	 					  {
	 						  //安街日报表
	 						  var addedStatus1 = ywBusiness.addedStatus1;
	 						  if(addedStatus1 == 10)
	 						  {
	 							 $("#added_status1").addClass("bg-green");
	 						  }
	 						  else if(addedStatus1 > 10)
	 						  {
	 							 $("#added_status1").addClass("bg-grey");
	 						  }
	 						  
	 						  //主状态值
	 						  var busiStatus = ywBusiness.busiStatus;
	 						  if(busiStatus == 330)
	 						  {
	 							  $('#dianzi').addClass("bg-green");
	 						  }
	 						  else if(busiStatus > 330)
	 						  {
	 							 $("#dianzi").addClass("bg-grey");
	 						  }
	 						  
	 						  //稽核审查
	 						  if(busiStatus == 290)
	 						  {
	 							 $('#M_jhsc').addClass("bg-green");
	 						  }
	 						  else if(busiStatus > 290)
	 						  {
	 							 $("#M_jhsc").addClass("bg-grey");
	 						  }
	 						  
	 						  //财务审核1
	 						  if(busiStatus == 300)
	 						  {
	 							 $('#M_cwshy').addClass("bg-green");
	 						  }
	 						  else if(busiStatus > 300)
	 						  {
	 							 $("#M_cwshy").addClass("bg-grey");
	 						  }
	 						  
	 						  //财务审核2
	 						  if(busiStatus == 320)
	 						  {
	 							 $('#M_cwshe').addClass("bg-green");
	 						  }
	 						  else if(busiStatus > 320)
	 						  {
	 							 $("#M_cwshe").addClass("bg-grey");
	 						  }
	 						  
	 						  //财务垫款
	 						  if(busiStatus == 320)
	 						  {
	 							$('#caiwudiankuan').addClass("bg-green");
	 						  }
	 						  else if(busiStatus > 320)
	 						  {
	 							 $("#caiwudiankuan").addClass("bg-grey");
	 						  }
	 					  }
	 					  
	 					  //业务返利表
	 					  var cwRebate = datas.cwRebate;
	 					  if(cwRebate)
	 					  {
	 						 $("#cwRebate").addClass("bg-grey");
	 					  }
	 					  
	 					  //财务审核3
	 					  var fkAuditList = datas.fkAuditList;
	 					  if(fkAuditList)
	 					  {
	 						  //审核状态
	 						  var statusList = fkAuditList.statusList;
	 						  
	 						  if(statusList == 1)
	 						  {
	 							  $('#caiwu3').addClass("bg-green");
	 						  }
	 						  else if(statusList == 2)
	 						  {
	 							 $("#M_cwshe").addClass("bg-grey");
	 						  }
	 						  else
	 						  {
	 							  //则标为白色
	 						  }
	 					  }
	 					  return;
	 				  }
	 				  if(datas.flag == "100200")
	 				  {
	 					  alert(JSON.stringify(datas));
	 					  return;
	 				  }
	 				  layer.msg(datas.message, {icon: 5});
	 		     }
	 		});
    	}
    	
    	//保存执行
    	var save = function()
    	{	
  	    	var validstatus = $("#commentForm").valid();
    		if(validstatus)
    		{
    				layer.confirm('确认要执行申请返利吗？操作人：<span style="color:#BD1723;">${current_user_key.uname}</span>', {
    		 		  btn: ['确定','取消'] //按钮
    		 		}, function(){
    		 			layer.closeAll();
    		 			var busiId = $('#busiId').val();
    		 			var amount_rebate = $('#amount_rebate').val();
    		 			$.dpAjax({
    			 			url:'${basePath}/CaiWuXiangGuanController/ywTiChengSave',
    			 			data:{
    			 				"busiId":busiId,
    			 				"amountRebate":amount_rebate
    			 			},
    			 			success: function(datas)
    			 			{
    			 				  if(datas.flag == "100100")
    			 				  {		
    			 					  layer.msg('执行返利成功！', {icon: 6});
	   			 					  setTimeout(function () {
	   			 						 window.location.href = "${basePath}/web/caiWuXiangGuan/dengjiYWtichengList.jsp";
	   			 					  }, 3000);
    			 					  return;
    			 				  }
    			 				  if(datas.flag == "100200")
    			 				  {
    			 					  alert(JSON.stringify(datas));
    			 					  return;
    			 				  }
    			 				  layer.msg(datas.message, {icon: 5});
    			 		     }
    			 		});
    		 		}, function(){
    		 			layer.msg('已取消本次操作！', {icon: 6});
    		 		});	
    		}
    		else{
    			layer.msg("有验证未通过，请检查",{icon:7});
    		}
    	}
    </script>
</body>
</html>
